package com.pzhu.service.impl;

import com.pzhu.dao.BookDao;
import com.pzhu.dao.impl.BookDaoImpl;
import com.pzhu.pojo.Book;
import com.pzhu.service.BookService;

import java.util.List;

public class BookServiceImpl implements BookService {
    private BookDao bookDao = new BookDaoImpl();
    @Override
    public int addBook(Book book) {
        return bookDao.addBook(book);
    }

    @Override
    public int deleteBook(Long id) {
        return bookDao.deleteBook(id);
    }

    @Override
    public Book selectBook(Long id) {
        return bookDao.selectBook(id);
    }

    @Override
    public List<Book> selectAllBook() {
        return bookDao.selectAllBook();
    }

    @Override
    public int updateBook(Book book) {
        return bookDao.updateBook(book);
    }

    @Override
    public long selectLastId() {
        int lastId;
        List<Book> bookList = bookDao.selectAllBook();
        Book book = bookList.get(bookList.size() - 1);
        return book.getId();
    }
}
